﻿// JScript 文件

function BASEisNotFloat(theFloat)
        {
            //判断是否为浮点数
            len=theFloat.length;
            dotNum=0;
            if (len==0)
            return true;
            for(var i=0;i<len;i++){
            oneNum=theFloat.substring(i,i+1);
            if (oneNum==".")
            dotNum++;
            if ( ((oneNum<"0" || oneNum>"9") && oneNum!=".") || dotNum>1)
            return true;
            }
            if (len>1 && theFloat.substring(0,1)=="0"){
            if (theFloat.substring(1,2)!=".")
            return true;
            }
            return false;
        }
        
function BASEisNotNum(theNum)
        {
            //判断是否为数字
            if (theNum.trim()=="")
            return false;
            for(var i=0;i<theNum.length;i++){
            oneNum=theNum.substring(i,i+1);
            if (oneNum<"0" || oneNum>"9")
            return true;
            }
            return false;
        }
        
function   checkMail(str)   
              {   
                var   strReg="";                   
                var   r;   
                var   strText=str;   
                strReg=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i;                                   
                
                            
                r=strText.search(strReg);   
                if(r==-1)   
                return false //错误
                else   return true;   
              }
              
function isLaterDate(d){//和当前日期比较
        try{
            var now = new Date();
            var dateArr = d.split("-");
            var arrLen = dateArr.length;

            now.setFullYear(now.getYear(), now.getMonth(), now.getDate());

            var checkDate = new Date();
            checkDate.setFullYear(dateArr[0], dateArr[1]-1, dateArr[2]);

            var nowTime = now.getTime();
            var checkTime = checkDate.getTime();

            if(nowTime < checkTime){
                return true;
            }else{
                return false;
            }
        }catch(e){return false;}
        }
        
function isLaterDate_tow(d,d1){//比较两个日期
        try{        
            var dateArr = d.split("-");
            var arrLen = dateArr.length;
            
            var dateArr1 = d1.split("-");
            var arrLen1 = dateArr1.length;
            
            var now = new Date();
            now.setFullYear(dateArr1[0], dateArr1[1]-1, dateArr1[2]);

            var checkDate = new Date();
            checkDate.setFullYear(dateArr[0], dateArr[1]-1, dateArr[2]);

            var nowTime = now.getTime();
            var checkTime = checkDate.getTime();

            if(nowTime <= checkTime){
                return true;
            }else{
                return false;
            }
            }catch(e){return false;}
        }
        
function clearinp()//清空所以输入框
    {
        inp=document.getElementsByTagName("input");
        for(var i=0;i<inp.length;i++)
        {
            if(inp[i].type=="text")
            {
                inp[i].value="";
            }
        }
        return false;
    }
    
function checkall(id,kind)//全选(kind可以是checkbox或者radio)
    {
        checkbox=document.getElementById(id).getElementsByTagName("input");
        for(var i=0;i<checkbox.length;i++)
        {       
            if(checkbox[i].type==kind)    
                checkbox[i].checked=true;
        }
    }
    
        
function checknotall(id,kind)//反选(kind可以是checkbox或者radio)
    {
        checkbox=document.getElementById(id).getElementsByTagName("input");
        for(var i=0;i<checkbox.length;i++)
        {       
            if(checkbox[i].type==kind)    
                checkbox[i].checked=false;
        }
    }
 
 
function addspan(obj,text)//添加元素（红色*号）removeChild
    { 
        var olddiv;
        if(obj==null)
        {
            olddiv=null;
        }  
        else
        {
            olddiv = document.getElementById(obj.id+"span"); 
        }   
        if(olddiv==null)  
        {        
            var span=document.createElement("span");
            span.innerHTML=text;
            span.className="red";
            span.type="red";
            span.id=obj.id+"span";
            obj.parentNode.appendChild(span,obj);  
        }
     
    }

function delspan(obj)//添加元素（红色*号）
    {    
        var olddiv;
        if(obj==null)
        {
            olddiv=null;
        }  
        else
        {
            olddiv = document.getElementById(obj.id+"span"); 
        }   
        if(olddiv!=null)
        {
            olddiv.innerHTML=""; 
            olddiv.className="";
            olddiv.type="";
            olddiv.id=obj.id+"";
        }
    }

function clearspan()//清除所有的span（红色*号）
    {
        var spans=document.getElementsByTagName("span");
            for(var i=0;i<spans.length;i++)
            {
                if(spans[i].type=="red"&&spans[i].className=="red")
                {
                    spans[i].innerHTML="";
                    spans[i].className="";
                    spans[i].type="";
                    spans[i].id="";
                }
            }
    }    